﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit%>
<%
Dim RZ_IN
RZ_IN=1
%>
<!--#include file="../conn.inc.asp" -->
<!--#include file="admin_inc/admin.function.asp" -->
<!--#include file="admin_inc/admin.sqlfunction.asp" -->
<%
'作者：山林客（ah_bill）
'博客：http://ruizhinet.blog.163.com
'网站：http://www.ruizhinet.cn
'本信息不会影响您网站的正常访问，请保留
checkadmin(4)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>模板管理</title>
<link type="text/css" href="style/style.css" rel="stylesheet" rev="stylesheet"/>
<script type="text/javascript" src="admin_js/common.js"></script> 
</head>
<body>
<%
Dim ftype
ftype=Trim(request("ftype"))
Dim ftypename,fexample
Select Case ftype
	Case 0:
		ftypename="HTML"
		fexample="articlelist.html"
	Case 1:
		ftypename="CSS"
		fexample="style.css"
	Case 2:
		ftypename="JavaScript"
		fexample="common.js"
	Case 3:
		ftypename="XML"
		fexample="ads.xml"
	Case 4:
		ftypename="Text"
		fexample="ads.txt"
End Select 

dim rootuploadpath,subdir,currentdir,myfilename,filepath,addedit
dim appPath
appPath=replace(LCase(Request.ServerVariables("PATH_INFO")), "admin/manage_template_edit.asp","" )
rootuploadpath = appPath&"template"
addedit=trim(request("addedit"))
currentdir=trim(request("subdir"))
currentdir=Replace(currentdir,"//","/")
myfilename=trim(request.QueryString("file"))
If myfilename<>"" Then 
	If ftype=0 And addedit="edit"  Then 
		myfilename=myfilename&".html"
	End If 
End If 
if myfilename="" then
	myfilename=trim(request.Form("file"))
end If

filepath=currentdir&"/"&myfilename

%>

<%
Dim act,content
act=trim(request.Form("act"))
content=Entity2Lt(Trim(request.Form("content")))
If act="savefile" Then 
	Call SaveFile(filepath,content)
	response.write("<script type='text/javascript'>alert('保存成功！');location.href='manage_template.asp?subdir="&currentdir&"';</script>")
End If 

Function Lt2Entity(content)
If IsNull(content) Or content="" Then Exit Function 
Lt2Entity=Replace(content,"<","&#60;")
End Function 

Function Entity2Lt(content)
If IsNull(content) Or content="" Then Exit Function 
Entity2Lt=Replace(content,"&#60;","<")
End Function 
%>
<form method="post" id="rzform" name="rzform" action="manage_template_edit.asp">
<table class="table_800" cellspacing="0" cellpadding="0">
<input type="hidden" name="act" id="act" value="savefile"/>
<input type="hidden" name="ftype" id="ftype" value="<%=ftype%>"/>
<input type="hidden" name="addedit" id="addedit" value="edit"/>
<input type="hidden" id="subdir" name="subdir" value="<%=currentdir%>" size="30" readonly="readonly"/>
<tr>
	<th colspan="2"><%If myfilename="" then%>添加<%else%>编辑<%End If%><%=ftypename%>文件</th>
</tr>
<tr  class="row">
<td colspan="2">
<textarea id="content" name="content" rows="20" cols="98">
<%=Lt2Entity(ReadFile(filepath))%>
</textarea>
</td>
</tr>
<tr  class="row">
<td><%If Right(myfilename,4)<>".css" then%>HTML<%else%>CSS<%End if%>文件名称：</td><td><input type="text" name="file" id="file" size="30" value="<%=myfilename%>" <%If addedit="edit" Then response.write("readonly=""readonly"" style=""color:#C0C0C0;""") End If%>
/>例：
<%=fexample%>
</td>
</tr>
<tr  class="row">
	<td class="tdcenter" colspan="2"><input type="button" class="btn"  value="<%out("lang_save")%>"  onclick="saveHTML();"/>&nbsp;&nbsp;<input type="button" class="btn"  value="<%out("lang_back")%>" onclick="javascript:location.href='manage_template.asp?subdir=<%=currentdir%>';"/><%If ftype=0  then%>&nbsp;&nbsp;<input type="button" class="btn"  value="<%out("lang_preview")%>" onclick="previewHTML();"/><%End if%></td>
</tr>
</table>
</form>
<br/>
<br/>
<div style="width:400px;margin:0px auto;color:red;">文件名命名规范<br/>
<img src="images/filenames.gif" width="435" height="373" alt="" /></div>

</body>
</html>